Skip to content

Deprecate runtime telemetry individual metric classes#16064

Merged
trask merged 3 commits intoopen-telemetry:mainfrom
trask:runtime-telemetry
Jan 30, 2026
Merged

Deprecate runtime telemetry individual metric classes#16064
trask merged 3 commits intoopen-telemetry:mainfrom
trask:runtime-telemetry

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Jan 29, 2026

Towards

I think metric view are good enough to include/exclude individual metrics as needed, so can remove these from public API.

cc @roberttoyonaga

@trask trask force-pushed the runtime-telemetry branch from 39023c9 to 9a8a9bb Compare January 29, 2026 21:00
@trask trask force-pushed the runtime-telemetry branch from 9a8a9bb to b4d9d99 Compare January 29, 2026 21:53
@trask trask marked this pull request as ready for review January 29, 2026 22:57
@trask trask requested a review from a team as a code owner January 29, 2026 22:57
observables.addAll(MemoryPools.registerObservers(openTelemetry));
observables.addAll(Threads.registerObservers(openTelemetry));
observables.addAll(
io.opentelemetry.instrumentation.runtimemetrics.java8.Classes.registerObservers(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason to use FQN here ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is usually done so because importing deprecated classes causes warnings that can't be suppressed and the build is configured to fail on warnings

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's annoying...

observables.addAll(
io.opentelemetry.instrumentation.runtimemetrics.java8.Threads.registerObservers(
openTelemetry));
if (emitExperimentalTelemetry) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we suggest using metric views to filter experimental metrics, does this means we would also get rid of this condition or do we still keep it ? From what I understand here the goal for now is only to make the individual metric classes internal.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we keep it, at least for now. We could consider removing it after open-telemetry/opentelemetry-specification#4809, though we could also keep it even then as "emit experimental telemetry" is a pattern we use throughout.

runtimeMetrics.close();
```

To select specific metrics, configure [metric views](https://opentelemetry.io/docs/specs/otel/metrics/sdk/#view)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an example implementation with Java SDK we could link to ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @deprecated Use {@link io.opentelemetry.instrumentation.runtimemetrics.java8.RuntimeMetrics}
* instead, and configure metric views to select specific metrics.
*/
@Deprecated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is an internal class we don't really need to do anything with it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to think of .internal.Experimental* as one step above other .internal classes. since easy in this case (and doesn't require annoying copy), I'd suggest go ahead with deprecation (but agree we don't necessarily need to)

* @deprecated Use {@link RuntimeMetrics} instead, and configure metric views to select specific
* metrics.
*/
@Deprecated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if your goal is just to move these to internal then maybe it would be easier to move the class, drop final, add deprecated class in original location that extends the moved class

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in cfbec4d

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request deprecates individual runtime telemetry metric classes in favor of using the RuntimeMetrics API with metric views to control which metrics are emitted. This change simplifies the public API by moving implementation classes to an internal package while maintaining backward compatibility through deprecated wrapper classes.

Changes:

  • Moved implementation classes (Classes, Cpu, GarbageCollector, MemoryPools, Threads) from public API to internal package
  • Deprecated public API classes with delegation to internal implementations
  • Marked experimental metric classes (ExperimentalBufferPools, ExperimentalCpu, ExperimentalMemoryPools, ExperimentalFileDescriptor) as deprecated
  • Updated README with comprehensive examples showing how to use RuntimeMetrics with metric views for selective metric collection

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Classes.java (public API) Converted to deprecated wrapper that delegates to internal implementation
Cpu.java (public API) Converted to deprecated wrapper that delegates to internal implementation
GarbageCollector.java (public API) Converted to deprecated wrapper that delegates to internal implementation
MemoryPools.java (public API) Converted to deprecated wrapper that delegates to internal implementation
Threads.java (public API) Converted to deprecated wrapper that delegates to internal implementation
Classes.java (internal) New internal implementation class moved from public package
Cpu.java (internal) New internal implementation class moved from public package
GarbageCollector.java (internal) New internal implementation class moved from public package
MemoryPools.java (internal) New internal implementation class moved from public package
Threads.java (internal) New internal implementation class moved from public package
ExperimentalBufferPools.java Added @deprecated annotation with guidance to use RuntimeMetrics
ExperimentalCpu.java Added @deprecated annotation with guidance to use RuntimeMetrics
ExperimentalMemoryPools.java Added @deprecated annotation with guidance to use RuntimeMetrics
ExperimentalFileDescriptor.java Added @deprecated annotation with guidance to use RuntimeMetrics
JmxRuntimeMetricsFactory.java Updated to reference internal classes directly, added deprecation suppression
ClassesTest.java Moved to internal package with updated imports
CpuTest.java Moved to internal package with updated imports
GarbageCollectorTest.java Moved to internal package with updated imports
MemoryPoolsTest.java Moved to internal package with updated imports
ThreadsTest.java Moved to internal package with updated imports
ExperimentalBufferPoolsTest.java Added deprecation suppression annotation
ExperimentalCpuTest.java Added deprecation suppression annotation
ExperimentalMemoryPoolsTest.java Added deprecation suppression annotation
ExperimentalFileDescriptorTest.java Added deprecation suppression annotation
README.md Updated with new usage examples showing RuntimeMetrics API and metric view configuration

@trask trask merged commit 0ef71c8 into open-telemetry:main Jan 30, 2026
90 of 91 checks passed
@trask trask deleted the runtime-telemetry branch January 30, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants